<template>
    <div>
        <h2>房号信息显示页面</h2>
        <a href="/fhadd">房号录入</a>
        <br></br>
        <a href="https://localhost:7258/api/roomfh/dc">房号导出</a>
        <br></br>
           <a href="/fxxs">房型显示</a>
        <br></br>
             <a href="/pfxs">排房显示</a>
        <br></br>
        房号名称 <input type="text" v-model="que.fhmc">
        房号创建时间
        <input type="date" v-model="que.fhcjsj">
        
        <input type="button" value="查询" @click="xs">

        <table class="table">
            <thead>
                <tr>
                    <td>房号名称</td>
                    <td>房号备注</td>
                    <td>房号创建时间</td>
                    <td>房号录入时间</td>
                    <td>状态</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody>
                  <tr v-for="m in data">
                    <td>{{ m.fhmc }}</td>
                    <td>{{ m.fhbz }}</td>
                    <td>{{ moment(m.fhcjsj).format("YYYY-MM-DD hh:mm:ss") }}</td>
                    <td>{{ moment(m.fhnrsj).format("YYYY-MM-DD hh:mm:ss") }}</td>
                    <td>{{ m.zt?"上架":"下架"}}</td>
                    <td>
                    <input type="button" value="修改" @click="xg(m.fhid)">
                    <input type="button" value="修改状态" @click="xgzt(m.fhid)">

                    </td>
                </tr>
            </tbody>
        </table>

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { ref,onMounted, compile } from 'vue';
import { useRouter } from 'vue-router';

const stor= useRouter();

const data=ref([{
      "fhid": 0,
  "fhmc": "",
  "fhbz": "",
  "fhcjsj": "2025-06-16T08:30:24.214Z",
  "fhnrsj": "2025-06-16T08:30:24.214Z",
  "zt": true
}])

 const que=ref({
    fhmc:"",
    fhcjsj:null
    
 })
 onMounted(()=>{
    xs();
 })
 const xs=()=>{
    axios.get("https://localhost:7258/api/roomfh/fhxs",{params:que.value}).then(res=>{
        data.value=res.data
    })
 }
const xg=(a:any)=>{
     if(!confirm("确认修改吗")){
        return
    }
    stor.push({path:"/fhxg",query:{fhid:a}})
}
const xgzt=(a:any)=>{
    if(!confirm("确认修改状态吗")){
        return
    }
    axios.get("https://localhost:7258/api/roomfh/xgzt",{params:{fhid:a}}).then(res=>{
        if(res.data>0){
            alert("修改状态成功");
            xs();
        }else{
            alert("修改状态失败")
        }
    })
}

</script>

<style scoped>

</style>